#!/usr/bin/env node

const http = require('https'),
      url = require('url'),
      qs = require('querystring');
//url:http://localhost:8080/add?x=2&y=3

const x = process.argv[2],
      y = process.argv[3];

const addr =`http://localhost:8080/add?x=${x}&y=${y}`; 
http.createServer((req,res)=>{
  const addr = url.parse(req.url);
  if(addr.pathname==='/add'){
    const arg = qs.parse(addr.query);
    const r={};
    r.add=Number(arg.x)+Number(arg.y);
    res.end(JSON.stringify(r));
  }
}).listen(8080);
